package main

import (
	"encoding/json"
	"fmt"
	"io/ioutil"
	"net/http"
)
type Response struct {
	 Data int `json:"data"`
}

func Add(a, b int) Response {
	// 传输协议： http
	resp, _ := http.Get(fmt.Sprintf("http://localhost:8000/add?a=%d&b=%d", a, b))
	defer resp.Body.Close()
	body, _ := ioutil.ReadAll(resp.Body)
	rspData := Response{}
	_ = json.Unmarshal(body, &rspData)
	return rspData
}

func main(){
	res := Add(1, 2)
	fmt.Println(res)
}
